/******************************************
@Description:监管可视化-充值卡充值订单记录
@Time : 2020/12/1 15:04
@Author :lixiaojun
交换机=dataVisualization.cardPackageRcardRecharge

*******************************************/
package main

import (
	"context"
	"encoding/json"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	dataVisualization2 "git.900sui.cn/kc/rpcinterface/client/dataVisualization"
	"git.900sui.cn/kc/rpcinterface/interface/dataVisualization"
	"github.com/streadway/amqp"
)

func main() {
	rpcDataVisualization := new(dataVisualization2.CardPackageRcardRecharge).Init()
	defer rpcDataVisualization.Close()

	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("dataVisualization.log.cardPackageRcardRecharge"))

	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("dataVisualization.queue.cardPackageRcardRecharge"), func(msg amqp.Delivery) {
		var args dataVisualization.ArgsCardPackageRcardRecharge
		if err:=json.Unmarshal(msg.Body,&args);err!=nil{
			return
		}
		var reply bool
		if err := rpcDataVisualization.SetCardPackageRcardRecharge(context.Background(), &args, &reply); err != nil {
			utils.Logerr.Printf("充值卡记录成功,监管可视化-充值卡充值记录任务调用失败，充值记录编号RechargeSn：%s err:%s\n", args.CardPackageCardSn, err.Error())
			return
		}

	})

	if err != nil {
		utils.Logerr.Printf("充值卡记录成功异步回调任务错误，err:%s\n", err.Error())
	}
}
